import { AfterViewInit, Component, OnDestroy, OnInit } from '@angular/core';
import { AuthGuard } from '../auth-guard.service';
import {parse, markdown} from 'markdown' ;


@Component({
  selector: 'app-compoment1',
  templateUrl: './compoment1.component.html',
  styleUrls: ['./compoment1.component.less']
})
export class Compoment1Component implements OnInit, AfterViewInit, OnDestroy {

  constructor(
    private guard: AuthGuard
  ) {
  }
    title = '标题';
  timer: any ;
  mode = false;
  dark = false;
  isCollapsed= false 
  menus = [
    {
      level: 1,
      title: 'Mail Group',
      icon: 'mail',
      open: true,
      selected: false,
      disabled: false,
      children: [
        {
          level: 2,
          title: 'Group 1',
          icon: 'bars',
          open: false,
          selected: false,
          disabled: false,
          children: [
            {
              level: 3,
              title: 'Option 1',
              selected: false,
              disabled: false
            },
            {
              level: 3,
              title: 'Option 2',
              selected: false,
              disabled: true
            }
          ]
        },
        {
          level: 2,
          title: 'Group 2',
          icon: 'bars',
          selected: true,
          disabled: false
        },
        {
          level: 2,
          title: 'Group 3',
          icon: 'bars',
          selected: false,
          disabled: false
        }
      ]
    },
    {
      level: 1,
      title: 'Team Group',
      icon: 'team',
      open: false,
      selected: false,
      disabled: false,
      children: [
        {
          level: 2,
          title: 'User 1',
          icon: 'user',
          selected: false,
          disabled: false
        },
        {
          level: 2,
          title: 'User 2',
          icon: 'user',
          selected: false,
          disabled: false
        }
      ]
    }
  ];
  mdHtml = ''
  ngOnInit(): string {
    // this.timer = setInterval(() => {}, 100);

    fetch('../../assets/example.md').then((res)=> {
      res.text().then((md)=> {
        this.mdHtml = markdown.toHTML(md) ;
        console.log( md, this.mdHtml)
      })
    })

    return '';
  }
  async ngAfterViewInit(): Promise<any>{
      document.getElementById('3d');
  }
  handler(e): void{

  }
  

  ngOnDestroy(): void {
    clearInterval(this.timer) ;
  }

}
